import request from '@/utils/request.js'

/**
 * 获取文章列表
 * @param {*} params{ with_top,timestamp,channel_id}
 */
export function getArticleList (params) {
  return request({
    url: '/v1_1/articles',
    params
  })
}

/**
 * 获取所有频道列表
 */
export function getAllChannel () {
  return request({
    url: '/v1_0/channels'
  })
}

export function getArticleDetail (id) {
  return request({
    url: '/v1_0/articles/' + id
  })
}

/**
 * 收藏文章
 * @param {*} target 要收藏的文章ID
 */
export function addCollectArticle (target) {
  return request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data: {
      target
    }
  })
}

/**
 * 取消收藏文章
 * @param {*} target 要取消收藏的文章ID
 */
export function deleteCollectArticle (target) {
  return request({
    url: '/v1_0/article/collections/' + target,
    method: 'DELETE'
  })
}

/**
 * 获取评论列表
 * @param {*} params {type,source,offset,limit}
 */
export function getCommentList (params) {
  return request({
    url: '/v1_0/comments',
    params
  })
}

/**
 * 添加评论或评论回复
 * @param {*} params {target,content,art_id}
 */
export function PostComment (data) {
  return request({
    url: '/v1_0/comments',
    method: 'POST',
    data
  })
}
